package com.dreamstations.changshads.adapter;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.support.v4.view.PagerAdapter;

import com.dreamstations.changshads.util.L;

import java.util.List;

/**
 * Created by QYH on 2016/5/12.
 */
public class Home_FragmentAdapter extends FragmentStatePagerAdapter {
    private List<Fragment> fragments;

    public Home_FragmentAdapter(FragmentManager fm, List<Fragment> fragments) {
        super(fm);
        this.fragments = fragments;
    }

    @Override
    public Fragment getItem(int position) {
        return fragments.get(position);
    }

    @Override
    public int getItemPosition(Object object) {
        return PagerAdapter.POSITION_NONE;
    }

    @Override
    public int getCount() {
        return fragments.size();
    }

    @Override
    public CharSequence getPageTitle(int position) {
        Bundle argument = getItem(position).getArguments();
        if (argument != null) {
            String title = argument.getString("title");
            if (title != null) {
                return title;
            }
        }
        return "TAB" + String.valueOf(position);
    }
}
